unit FKeys;

interface
uses
	Windows, Forms, FLoader, FLogs, SysUtils;

var
	KeyList : array[0..400] of Integer;

const
	FO_LEFT = 0;
	FO_RIGHT = 1;
	FO_UP = 2;
	FO_DOWN = 3;
                                          
procedure InitKeys();      
function isKeyDown(key : Integer) : boolean;  
function isWinKeyDown(key : Integer) : boolean;    
procedure HandleKey(key : integer);

implementation

function isKeyDown(key : Integer) : boolean;
begin
	Result := (GetKeyState(KeyList[key]) AND 128) = 128;
end;

function isWinKeyDown(key : Integer) : boolean;
begin
	Result := (GetKeyState(key) AND 128) = 128;
end;

// http://delphi.about.com/od/objectpascalide/l/blvkc.htm
procedure InitKeys();
begin
	KeyList[FO_LEFT] 		:= VK_LEFT;
	KeyList[FO_RIGHT] 	:= VK_RIGHT;
	KeyList[FO_UP] 			:= VK_UP;
	KeyList[FO_DOWN] 		:= VK_DOWN;
end;

procedure HandleKey(key : integer);
begin
	if Key = VK_ESCAPE then
		Application.Terminate;
	if Key = VK_F1 then
		LoadedModel.LoadMDX('Models/AltarOfKings.mdx');
end;

end.

